
$(function(){

    $("#Add").dialog({
        title:"添加",
        btnName:"添加",
        btnBind:function(){
            var params=$("#table1").bootstrapTable("getSelections");
            console.info(params);
            $(params[0]).each(function () {
                console.info(this)
                $("#DictionaryForm").setForm(this);
                $("#DictionaryForm input[name='type1']").val($("#DictionaryForm input[name='type']").val()==0?"低值":"高值")
                $("#DictionaryForm input[name='applyChildNum']").val(1)
            })
            $("#Add").dialog("close");
        }
    });
});
function searchTjDictionary() {
    var param=$("#condition1").serializeArray();
    console.info(param)

    var obj={};
    for(var i in param){
        obj[param[i].name]=param[i].value;
    }
    $("#table1").bootstrapTable("refresh",{query:obj});

}

function FormatType(val,row,index) {
    if(val=='1'){
        return "高值";
    }else{
        return "低值";
    }
}


function FormatOperation(value,row,index){
    var peration = "<span class='btn btn-default' onclick='update("+JSON.stringify(row)+")'><i class='glyphicon glyphicon-edit'></i>修改</span>&nbsp;<span class='btn btn-warning' onclick='delete1("+row.applyChildId+")'><i class='glyphicon glyphicon-remove'></i>删除</span>";
    return peration;
}
function xuanzewuzi() {
    $("#xg").addClass("hidden");
    $("#bc").removeClass("hidden");
    $(".modal .modal-body #Add").attr("class","show");
    $("#Add").dialog("open");
}

function delete1(id) {
    var param="id="+id;
    $.post("apply/handApply/delApplyChild",param,function (msg) {
        toastr.warning(msg);
        $("#table").bootstrapTable("refresh")
    },"text")
}

function update(row) {
    $("#bc").addClass("hidden");
    $("#xg").removeClass("hidden");
    $("#DictionaryForm").setForm(row);
    $("#DictionaryForm input[name='type1']").val(row.dictionary.type==0?"低值":"高值");
    $("#DictionaryForm input[name='type']").val(row.dictionary.type);
    $("#DictionaryForm input[name='cgName']").val(row.dictionary.cgName);
    $("#DictionaryForm input[name='spec']").val(row.dictionary.spec);
    $("#DictionaryForm input[name='packUnit']").val(row.dictionary.packUnit);

}










